package com.tourism.home.controller.user;

import com.tourism.home.entity.Result;
import com.tourism.home.service.CommentService;
import com.tourism.home.utils.ResultUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class CommentController {
    @Autowired
    CommentService commentService;

    //ok
    @GetMapping("/comment/info/{pid}")
    Result getCommentByPID(@PathVariable("pid") Integer pid){
        return ResultUtil.success(commentService.getCommentByPID(pid));
    }
    //ok
    @PutMapping("/comment/add")
    Result addComment(@RequestParam("pid") Integer pid, @RequestParam("content") String content, @RequestParam("commentator") Integer commentator, @RequestParam("becommented") Integer becommented, @RequestParam("type") String type){
        return ResultUtil.success(commentService.addComment(pid,content,commentator,becommented,type));
    }
}
